package org.usmile.algorithms.huawei.acm;

import java.util.Scanner;
import java.util.Stack;

// https://blog.csdn.net/qq_34465338/article/details/128736405
public class _简单的解压缩算法 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        Stack<String> stack = new Stack<>();
        StringBuilder sb  = new StringBuilder();
        int i = 0;
        while (i < S.length()) {
            char c = S.charAt(i);
            if (Character.isLetter(c)) {
                if (i < S.length() - 1 && Character.isDigit(S.charAt(i + 1))) {
                    int count = 0;
                    int j = i + 1;
                    while (j < S.length() && Character.isDigit(S.charAt(j))) {
                        count = count * 10 + (S.charAt(j) - '0');
                        j++;
                    }
                    i = j;
                    sb.append(String.valueOf(c).repeat(Math.max(0, count)));
                } else {
                    sb.append(c);
                    i++;
                }
            } else if (c == '{') {
                if (sb.length() != 0) {
                    stack.push(sb.toString());
                }
                i++;
                sb.delete(0, sb.length());
            } else if (c == '}') {
                i++;
                int count = 0;
                while(i < S.length() && Character.isDigit(S.charAt(i))){
                    count = count * 10 + (S.charAt(i) - '0');
                    i++;
                }
                String temp = sb.toString();
                sb.delete(0, sb.length());
                temp = temp.repeat(Math.max(0, count));
                if (!stack.isEmpty()) {
                    sb.append(stack.pop());
                }
                sb.append(temp);
            }
        }

        System.out.println(sb.toString());
    }
}
